package demo2;

import java.util.Random;

public class Role {
    private String name;
    private int blood;
    private char gender;
    private String face;
    String[] boyface = {"风流俊雅", "气宇轩昂", "相貌英俊", "五官端正", "相貌平平", "一塌糊涂", "面目狰狞"};
    String[] girlface = {"美奂绝伦", "沉鱼落雁", "亭亭玉立", "身材姣好", "相貌平平", "相貌简陋", "惨不忍睹"};
    String[] attack_method = {
            "%s使出了一招【仙女散花】，对其进行连环攻击。",
            "%s使出了一招【天马流星锤】，对其锁喉。",
            "%s使出了一招【霹雷坠地】，锤向双腿。",
            "%s使出了一招【掌心雷】，将雷电推了过去",
            "%s阴手翻起阳手跟进，一手【没遮拦】，结结实实的锤向了她"
    };
    String[] injureds_method = {
            "结果%s退了半步，毫发无伤",
            "结果给%s造成一处瘀伤",
            "结果一击命中，%s痛的弯下了腰",
            "结果%s受了点内伤",
            "结果%s像软泥一样趴倒在地，起不来",
    };

    public Role() {
    }

    public Role(String name, int blood, char gender) {
        this.name = name;
        this.blood = blood;
        this.gender = gender;
        setFace(gender);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getBlood() {
        return blood;
    }

    public void setBlood(int blood) {
        this.blood = blood;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public String getFace() {
        return face;
    }

    public void setFace(char gender) {
        Random r = new Random();
        if (gender == '男') {
            int index = r.nextInt(boyface.length);
            this.face = boyface[index];
        } else if (gender == '女') {
            int index = r.nextInt(girlface.length);
            this.face = girlface[index];
        } else {
            this.face = "未知面貌";
        }
    }

    public void attack(Role role) {
        Random r = new Random();
        int index = r.nextInt(attack_method.length);
        String gongfu = attack_method[index];
        System.out.printf(gongfu, this.getName(), role.getName());
        int hurt = r.nextInt(20) + 1;
        int remainblood = role.getBlood() - hurt;
        remainblood = remainblood < 0 ? 0 : remainblood;
        role.setBlood(remainblood);
        System.out.println();
//        System.out.println(this.getName()+"举起拳头，打了"+role.getName()+"一下，"+"造成了"+hurt+"点伤害，"+role.getName()+"还剩下了"+remainblood+"点血");
        if (remainblood > 80) {
            System.out.printf(attack_method[0], role.getName());
        } else if (remainblood > 60 && remainblood <= 80) {
            System.out.printf(attack_method[1], role.getName());
        } else if (remainblood > 40 && remainblood <= 60) {
            System.out.printf(attack_method[2], role.getName());
        } else if (remainblood > 20 && remainblood <= 40) {
            System.out.printf(attack_method[3], role.getName());
        } else {
            System.out.printf(attack_method[4], role.getName());
        }
    }

    public void info() {
        System.out.println("姓名为：" + getName());
        System.out.println("血量为：" + getBlood());
        System.out.println("性别为：" + getGender());
        System.out.println("长相为：" + getFace());
    }
}